package club.beimeng.Thread;

import javax.annotation.security.RunAs;

public class ThreadTest implements Runnable {
    private int tick = 40;

    @Override
    public void run() {
        while (true){
            if(tick > 0) {
                tick--;
                System.out.println(Thread.currentThread().getName()+"卖出一张，还剩" + tick + "张");
            }else{
                System.out.println("票已售完！");
                break;
            }
        }
    }
}
class Test {
    public static void main(String[] args) {
        ThreadTest ticket = new ThreadTest();
        Thread windows1 = new Thread(ticket,"窗口1");
        Thread windows2 = new Thread(ticket,"窗口2");
        Thread windows3 = new Thread(ticket,"窗口3");
        Thread windows4 = new Thread(ticket,"窗口4");
        windows1.start();
        windows2.start();
        windows3.start();
        windows4.start();
    }
}
